package com.ly.hotel.view.common.msg;

import android.content.Context;
import android.view.View;
import android.view.WindowManager;

public class MarqueeToast
{
  private Context context;
  private int mGravity = 81;
  float mHorizontalMargin;
  private final WindowManager.LayoutParams mParams = new WindowManager.LayoutParams();
  float mVerticalMargin;
  View mView;
  WindowManager mWindowManager;
  private int mX;
  private int mY;

  public MarqueeToast(Context paramContext)
  {
    this.context = paramContext;
    this.mWindowManager = ((WindowManager)paramContext.getSystemService("window"));
    WindowManager.LayoutParams localLayoutParams = this.mParams;
    localLayoutParams.height = -2;
    localLayoutParams.width = this.mWindowManager.getDefaultDisplay().getWidth();
    localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
    localLayoutParams.flags = 40;
    localLayoutParams.format = -3;
    localLayoutParams.setTitle("Toast");
  }

  public void hid()
  {
    if ((this.mView != null) && (this.mView.getParent() != null))
      this.mWindowManager.removeView(this.mView);
  }

  public void setGravity(int paramInt1, int paramInt2, int paramInt3)
  {
    this.mGravity = paramInt1;
    this.mX = paramInt2;
    this.mY = paramInt3;
  }

  public void setGravity(int paramInt1, int width, int x, int y)
  {
    this.mGravity = paramInt1;
//    this.mX = x;
    this.mY = y;
    this.mParams.width = width;
  }

  public void setHeight(int paramInt)
  {
    this.mParams.height = paramInt;
  }

  public void setMargin(float paramFloat1, float paramFloat2)
  {
    this.mHorizontalMargin = paramFloat1;
    this.mVerticalMargin = paramFloat2;
  }

  public void setView(View paramView)
  {
    this.mView = paramView;
  }

  public void setWidth(int paramInt)
  {
    this.mParams.width = paramInt;
  }

  public void show()
  {
    try
    {
      if (this.mView != null)
      {
        int i = this.mGravity;
        this.mParams.gravity = i;
        if ((i & 0x7) == 7)
          this.mParams.horizontalWeight = 0.0F;
        if ((i & 0x70) == 112)
          this.mParams.verticalWeight = 0.0F;
        this.mParams.x = this.mX;
        this.mParams.y = this.mY;
        this.mParams.verticalMargin = this.mVerticalMargin;
        this.mParams.horizontalMargin = this.mHorizontalMargin;
        if (this.mView.getParent() != null)
          this.mWindowManager.removeView(this.mView);
        this.mWindowManager.addView(this.mView, this.mParams);
      }
      return;
    }
    catch (Exception localException)
    {
    }
  }
}